/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ca.jerg.canvas;

import javax.swing.undo.*;

import ca.jerg.data.ErgData;
import ca.jerg.data.ErgPoint;

/**
 *
 * @author dave
 */
public class EditRemove extends AbstractUndoableEdit
{
	public EditRemove( Canvas canvas, ErgData dataSet, ErgPoint dataPoint )
	{
		this.canvas = canvas;
		data = dataSet;
		point = dataPoint;
	}
	
	@Override
	public void undo() throws CannotUndoException
	{
		data.insertAt(point.getTime(), point);
		canvas.repaint();
	}
	
	@Override
	public void redo() throws CannotRedoException
	{
		data.remove(point.getTime());
		canvas.repaint();
	}
	
	@Override
	public boolean canUndo() 
	{
		return true;
	}

	@Override
	public boolean canRedo() 
	{
		return true;
	}

	@Override
	public String getPresentationName() 
	{
		return "Remove";
	}
	
	private Canvas canvas;
	private ErgData data;
	private ErgPoint point;
}
